<script setup>
import { ref } from 'vue'
let numbers = [4, 9, 16, 25];

// 1. 遍历
numbers.map(item => {
  console.log("item:" + item);
})
console.log("----------");

// 2. 遍历并且赋值给一个数组-方式1
let numbers2 = []
numbers.map(item => {
  numbers2.push(item)
})
console.log('numbers2: '+numbers2);
console.log("----------");

// // 3. 遍历并且赋值-方式2
let numbers3 = numbers.map(item => {
  numbers2.push(item)
  return item
})
console.log('numbers3: '+numbers3);
console.log("----------");

// 4. 测试index索引，索引从0开始。arr，当前元素属于的数组对象，也就是objArr
let objArr = [
  {
    phone: '100',
    name: 'xzs'
  },  
  {
    phone: '200',
    name: 'hzs'
  }
]

let objArr2 = []
objArr.map((item, index, arr) =>{
  let obj = {}
  obj.phone = item.phone
  obj.name = item.name
  obj.index = index
  objArr2.push(obj)
  console.log('obj: '+ obj);
})

</script>